<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
		div{
			padding: 10px 20px 30px;
		}
	</style>
</head>
<body>
	<div></div>

	<script type="text/javascript">
		//fetchComputedStyle(oDiv,”padding-left”);

		function fetchComputedStyle(obj , property){

			//能力检测
			if(window.getComputedStyle){
				//现在要把用户输入的property中检测一下是不是驼峰，转为连字符写法
				//强制把用户输入的词儿里面的大写字母，变为小写字母加-
				//paddingLeft  →  padding-left
				property = property.replace(/([A-Z])/g , function(match,$1){
					return "-" + $1.toLowerCase();
				});

				return window.getComputedStyle(obj)[property];
			}else{
				//IE只认识驼峰，我们要防止用户输入短横，要把短横改为大写字母
				//padding-left  → paddingLeft 
				property = property.replace(/\-([a-z])/g , function(match,$1){
					return $1.toUpperCase();
				});

				return obj.currentStyle[property];
			}
		}

		
		var oDiv = document.getElementsByTagName("div")[0];
		alert(fetchComputedStyle(oDiv,"padding-left"));
	</script>
</body>
</html>